import numpy as np


def show_result(f, g, x, it_n, it_ls, msg, fc, gc, hc, name):
    # print("%d %d %d+%d %s" % (it_n, it_ls, fc.count, gc.count, f(x)))
    print('found solution x*= (first 4 dims) %s' % x[:4])
    print('terminate reason: %s' % msg)
    print('Newton iterations: %d' % it_n)
    print('line search iterations: %d' % it_ls)
    print('f() calls: %d' % fc.count)
    print('g() calls: %d' % gc.count)
    print('G() calls: %d' % hc.count)
    print('f*= %s' % f(x))
    print('||g*||= %s' % np.sqrt(np.sum(g(x) ** 2)))
    print("ONE LINER: %s & %d & %d & %d+%d & %.4e & & \\\\" % (name, it_n, it_ls, fc.count, gc.count, f(x)))
